﻿using System;
using System.Collections.Generic;

namespace WareDealer.Mode
{
    /// <summary>
    /// 采集任务集
    /// </summary>
    public class GatherTask
    {
        private readonly string _taskId = Guid.NewGuid().ToString();
        /// <summary>
        /// 任务编号
        /// </summary>
        public string TaskID { get { return _taskId; } }
        /// <summary>
        /// 数字编号
        /// </summary>
        public int Num { get; set; }
        /// <summary>
        /// 需采集商品集合
        /// </summary>
        public List<ProductInfo> WareInfos { get; set; }
        /// <summary>
        /// 任务状态
        /// </summary>
        public EnumGatherStatu TaskStatu { get; set; }
        /// <summary>
        /// 任务类型
        /// </summary>
        public EnumGatherTaskType TaskType { get; set; }

        private string _taskTypeName = "价格";
        /// <summary>
        /// 任务类型名称
        /// </summary>
        public string TaskTypeName
        {
            get
            {
                switch (TaskType)
                {
                    case EnumGatherTaskType.Stock:
                        _taskTypeName = "库存";
                        break;
                    case EnumGatherTaskType.SubTitle:
                        _taskTypeName = "促销";
                        break;
                    case EnumGatherTaskType.Coupon:
                        _taskTypeName = "优惠";
                        break;
                    default:
                        _taskTypeName = "价格";
                        break;
                }
                return _taskTypeName;
            }
        }
        /// <summary>
        /// 输出消息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 关联进度条编号/名称
        /// </summary>
        public string ProcessBarID { get; set; }
    }
    /// <summary>
    /// 任务状态枚举
    /// </summary>
    public enum EnumGatherStatu
    {
        /// <summary>
        /// 初始化
        /// </summary>
        Initialize,
        /// <summary>
        /// 开始
        /// </summary>
        Begin,
        /// <summary>
        /// 执行中
        /// </summary>
        Exec,
        /// <summary>
        /// 结束
        /// </summary>
        End,
        /// <summary>
        /// 异常
        /// </summary>
        Error
    }
    /// <summary>
    /// 采集任务类型
    /// </summary>
    public enum EnumGatherTaskType
    {
        /// <summary>
        /// 价格
        /// </summary>
        Price,
        /// <summary>
        /// 库存
        /// </summary>
        Stock,
        /// <summary>
        /// 副标题/广告信息
        /// </summary>
        SubTitle,
        /// <summary>
        /// 优惠
        /// </summary>
        Coupon
    }
}
